<?php

namespace app\common\model;

use think\Exception;
use think\Model;

/**
 * 邮箱验证码
 */
class LocVideo extends Model
{

    protected $table = 'yzn_loc_video';
    protected $createTime = 'create_time';




    public function addLocVideo($params = array())
    {
        $date = date('Y-m-d');
        $locVideo = self::where(['day' => $date, 'loc_id' => $params['loc_id'],])->find();
        if ($locVideo) {
            $locVideo->video_num += 1;
        } else {
            $locVideo = (new self());
            $locVideo->day = $date;
            $locVideo->video_num = 1;
            $locVideo->uid = $params['uid'];
            $locVideo->loc_id = $params['loc_id'];
            $locVideo->create_time = time();
        }
        if (!$locVideo->save()) {
           return false;
        }
        return true;
    }

}
